/*
 * Index.fx
 * Author : Yu Min-ting
 * Created on 2009-7-9, 10:36:00
 */

package com.sjtu.fx;

import javafx.stage.*;

import javafx.scene.Scene;

import com.sjtu.fx.user.*;
import com.sjtu.fx.others.Link;
import com.sjtu.fx.book.*;

import com.sjtu.fx.admin.AdminControlPanel;
import com.sjtu.fx.admin.UpdateNewBooks;
import com.sjtu.fx.admin.PurchaseManagement;
import com.sjtu.fx.admin.UserManagement;


import javafx.scene.Group;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.effect.Reflection;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import java.lang.Void;

import com.sjtu.fx.admin.CheckManagement;

import com.sjtu.fx.admin.BookManagement;

var login: Login;
var register: Register;
var link: Link;
var searchBooks: SearchBooks;
var browseBooks: BrowseBooks;
var topBooks: TopBooks;
var recommendBooks: RecommendBooks;
var adminControl:AdminControlPanel;
var userControl:UserControlPanel;
var updateBookPanel:UpdateNewBooks;
var changePaswd:ChangePw;
var userManagemet:UserManagement;
var borrowBook:BookDetails;
var searchResult:SearchResults;
var bookPurchaseCheck:PurchaseManagement;
var userPurchaseRequest:PurchaseRequest;
var borrowBookCheck:CheckManagement;
var userBookPurchase:BookPurchase;
var userBookCheck:BorrowReturnBooks;
var bookManagement:BookManagement;
//navigations in the banner
var home:Text = Text{
     content: "Home          |"
     fill:Color.rgb(39,97,110)
     font: Font{ size:10 name: "Verdana Bold"}
     x: 615 y: 15

     onMouseEntered: function( e: MouseEvent ):Void {
             home.fill =  Color.BLACK;
             home.effect = Reflection {
            fraction: 0.75
            topOffset:-1.0
        }
         }
     onMouseExited: function(e:MouseEvent) {
            home.fill = Color.rgb(39,97,110);
            home.effect = null;
    }
    onMouseClicked: function( e: MouseEvent ):Void {
            recommendBooks.visible = true;
            topBooks.visible = true;
            searchResult.visible =false;
            register.visible = false;
            updateBookPanel.visible = false;
            changePaswd .visible = false;
            userManagemet.visible = false;
            borrowBook .visible = false;
            link.visible = true;
            bookPurchaseCheck.visible = false;
            userPurchaseRequest .visible = false;
            userBookPurchase.visible = false;
            searchResult.visible = false;
            userBookCheck .visible = false;
            bookManagement.visible = false;
            borrowBookCheck .visible = false;
             if(login.userid!=0){
                if(login.isAdmin == true){
                    adminControl.visible = true;
                }else{
                    userControl.visible = true;
                }
            }else{
                login.visible = true;
            }
    }
};

var books:Text = Text{
     content: "Books          |"
     fill:Color.rgb(39,97,110)
     font: Font{ size:10 name: "Verdana Bold"}
     x: 715 y: 15
     onMouseEntered: function( e: MouseEvent ):Void {
             books.fill =  Color.BLACK;
             books.effect = Reflection {
            fraction: 0.75
            topOffset:-1.0
        }
         }
     onMouseExited: function(e:MouseEvent) {
            books.fill = Color.rgb(39,97,110);
            books.effect = null
    }
    onMouseClicked: function( e: MouseEvent ):Void {
        //to do
        recommendBooks.visible = false;
        topBooks.visible = false;
        borrowBook .visible = true;
    }
};

var library:Text = Text{
     content: "My Library          |"
     fill:Color.rgb(39,97,110)
     font: Font{ size:10 name: "Verdana Bold"}
     x: 815 y: 15
     onMouseEntered: function( e: MouseEvent ):Void {
             library.fill =  Color.BLACK;
             library.effect = Reflection {
            fraction: 0.75
            topOffset:-1.0
        }
         }
     onMouseExited: function(e:MouseEvent) {
            library.fill = Color.rgb(39,97,110);
            library.effect = null
    }
    onMouseClicked: function( e: MouseEvent ):Void {
            borrowBook.visible = false;
            if(login.userid!=0){
                if(login.isAdmin == true){
                    adminControl.visible = true;
                }else{
                    userControl.visible = true;
                }
            }else{
                login.visible = true;
            }
    }
};

var about:Text = Text{
     content: "About Us"
     fill:Color.rgb(39,97,110)
     font: Font{ size:10 name: "Verdana Bold"}
     x: 935 y: 15
     onMouseEntered: function( e: MouseEvent ):Void {
             about.fill =  Color.BLACK;
             about.effect = Reflection {
            fraction: 0.75
            topOffset:-1.0
        }
         }
     onMouseExited: function(e:MouseEvent) {
            about.fill = Color.rgb(39,97,110);
            about.effect = null
    }
        onMouseClicked: function( e: MouseEvent ):Void {
        //to do
    }


};

var homeR: Rectangle = Rectangle{
    width:248 height:35
    x:4 y:75
    arcWidth: 10  arcHeight: 10
    fill:Color.rgb(200,225,230)
    effect:{
       GaussianBlur { radius: 63  }
        DropShadow{offsetX:5 offsetY:5 color: Color.GRAY}
    }
        onMouseEntered: function( e: MouseEvent ):Void {
            homeR.fill = Color.rgb(152, 190, 198)
    }
        onMouseExited: function(e:MouseEvent) {
            homeR.fill = Color.rgb(200,225,230)
    }
        onMouseClicked: function( e: MouseEvent ):Void {
        //to do
            recommendBooks.visible = true;
            topBooks.visible = true;
            searchResult.visible =false;
            register.visible = false;
            updateBookPanel.visible = false;
            changePaswd .visible = false;
            userManagemet.visible = false;
            borrowBook .visible = false;
            link.visible = true;
            bookPurchaseCheck.visible = false;
            userPurchaseRequest .visible = false;
            userBookPurchase.visible = false;
            searchResult.visible = false;
            userBookCheck .visible = false;
            bookManagement.visible = false;
            borrowBookCheck .visible = false;
             if(login.userid!=0){
                if(login.isAdmin == true){
                    adminControl.visible = true;
                }else{
                    userControl.visible = true;
                }
            }else{
                login.visible = true;
            }
    }
}

var bookR: Rectangle = Rectangle{
    width:248 height:35
    x:252 y:75
    fill:Color.rgb(200,225,230)
    effect:{
        GaussianBlur { radius: 63  }
        DropShadow{offsetX:5 offsetY:5 color: Color.GRAY}

    }
        onMouseEntered: function( e: MouseEvent ):Void {
            bookR.fill = Color.rgb(152, 190, 198)
    }
        onMouseExited: function(e:MouseEvent) {
            bookR.fill = Color.rgb(200,225,230)
    }
        onMouseClicked: function( e: MouseEvent ):Void {
        //to do
    }
}

var libraryR: Rectangle = Rectangle{
    width:248 height:35
    x:500 y:75
    fill:Color.rgb(200,225,230)
    effect:{
        GaussianBlur { radius: 63  }
        DropShadow{offsetX:5 offsetY:5 color: Color.GRAY}
    }
        onMouseEntered: function( e: MouseEvent ):Void {
            libraryR.fill = Color.rgb(152, 190, 198)
    }
        onMouseExited: function(e:MouseEvent) {
            libraryR.fill = Color.rgb(200,225,230)
    }
        onMouseClicked: function( e: MouseEvent ):Void {
            login.visible = true;
    }
}

var aboutR: Rectangle = Rectangle{
    width:248 height:35
    x:748 y:75
    arcWidth: 10  arcHeight: 10
    fill:Color.rgb(200,225,230)
    effect:{
        GaussianBlur { radius: 63  }
        DropShadow{offsetX:5 offsetY:5 color: Color.GRAY}
    }
        onMouseEntered: function( e: MouseEvent ):Void {
            aboutR.fill = Color.rgb(152, 190, 198)
    }
        onMouseExited: function(e:MouseEvent) {
            aboutR.fill = Color.rgb(200,225,230)
    }
        onMouseClicked: function( e: MouseEvent ):Void {
        //to do
    }
}


// banner of our web site
var banner = Group {
    translateX:12 translateY:5
    content: [
        // logo of our web site.
        ImageView {
            x:5 y:5
            image: Image {
                url: "{__DIR__}image/logo.png"
            }
        }
        // navigation of our web site
        home , books , library , about,
       //botton navigation of our web site
       homeR , bookR , libraryR , aboutR ,
       Text { content: "HOME" x: 106 y: 100 fill: Color.rgb(11,51,60)
        font: Font{ size:15 name: "Arial Bold"}}
       Text { content: "BOOKS" x: 354 y: 100 fill: Color.rgb(11,51,60)
        font: Font{ size:15 name: "Arial Bold"}}
       Text { content: "MY LIBRARY" x: 580 y: 100 fill: Color.rgb(11,51,60)
        font: Font{ size:15 name: "Arial Bold"}}
       Text { content: "ABOUT US" x: 840 y: 100 fill: Color.rgb(11,51,60)
        font: Font{ size:15 name: "Arial Bold"}}
        ]
};


// the main page
Stage {
    title: "Online book library";
    width: 1024
    height: 768
    scene:Scene {
    fill: Color.WHITE
    content: [
        banner ,
        register = Register{id:"register"translateX:225 translateY:135 visible:false}
        link = Link{translateX:715 translateY:400}
        searchBooks = SearchBooks{translateX:14 translateY:135}
        browseBooks = BrowseBooks{translateX:14 translateY:305}
        updateBookPanel = UpdateNewBooks{id:"updateBook" translateX:225 translateY:135 visible:false}
        changePaswd = ChangePw{id:"changePassWd" translateX:225 translateY:135 visible:false}
        userManagemet = UserManagement{id:"userManagemet" translateX:225 translateY:135 visible:false}
        borrowBook = BookDetails{id:"borrowBook" translateX:225 translateY:135 visible:false}
        bookPurchaseCheck = PurchaseManagement{id:"bookPurchaseCheck" translateX:225 translateY:135 visible:false}
        userPurchaseRequest = PurchaseRequest{id:"bookPurchaseRequest" translateX:225 translateY:135 visible:false}
        userBookPurchase = BookPurchase{id:"userBookPurchase" translateX:225 translateY:135 visible:false}
        searchResult = SearchResults{id:"searchResult"  translateX:225 translateY:135  visible:false}
        userBookCheck = BorrowReturnBooks{id:"userBookPage" translateX:225 translateY:135  visible:false}
        bookManagement = BookManagement{id:"bookManagement" translateX:225 translateY:135  visible:false}
        topBooks = TopBooks{id:"topBooks" translateX:225 translateY:135}
        borrowBookCheck = CheckManagement{id:"borrowBookCheck" translateX:225 translateY:135 visible:false}
        recommendBooks = RecommendBooks{id:"recommendBooks"translateX:225 translateY:400}
        adminControl = AdminControlPanel{id:"adminPanel" translateX:715 translateY:135 visible:false}
        userControl  = UserControlPanel{id:"userPanel" translateX:715 translateY:135 visible:false}
        login = Login{id:"loginPanel" translateX:715 translateY:135  }

        ]
};
    
}